from PyQt6.QtGui import QPixmap, QImage
import numpy as np


class ImageUtils:
    @staticmethod
    def numpy_to_qpixmap(image_array):
        """将numpy数组转换为QPixmap"""
        # 获取图片尺寸
        height, width, channel = image_array.shape
        bytes_per_line = 3 * width

        # 创建QImage
        q_img = QImage(image_array.data, width, height, bytes_per_line, QImage.Format.Format_RGB888)

        # 创建QPixmap
        return QPixmap.fromImage(q_img)
